#include "config_read.hpp"
#include <iostream>

void printSoftwareConfig(const config::SoftwareConfig& cfg) {
    std::cout << "\n=== Software Config ===" << std::endl;
    std::cout << "Version: " << cfg.basic.version << std::endl;
    std::cout << "Name: " << cfg.basic.name << std::endl;
    std::cout << "Environment: " << cfg.basic.env << std::endl;
    std::cout << "Thread Pool Size: " << cfg.system.thread_pool_size << std::endl;
    std::cout << "CUDA Enabled: " << (cfg.system.cuda_enabled ? "Yes" : "No") << std::endl;
}

void printCameraConfig(const config::CameraConfig& cfg) {
    std::cout << "\n=== Camera Config ===" << std::endl;
    std::cout << "Type: " << cfg.type << std::endl;
    std::cout << "Device ID: " << cfg.device_id << std::endl;
    std::cout << "Resolution: " << cfg.resolution.width << "x" << cfg.resolution.height << std::endl;
    std::cout << "Frame Rate: " << cfg.frame_rate << std::endl;
}

void printAlgorithmConfig(const config::AlgorithmConfig& cfg) {
    std::cout << "\n=== Algorithm Config ===" << std::endl;
    std::cout << "Model Name: " << cfg.model.name << std::endl;
    std::cout << "Model Type: " << cfg.model.type << std::endl;
    std::cout << "Model Path: " << cfg.model.path << std::endl;
    std::cout << "Device: " << cfg.model.device << std::endl;
    std::cout << "Batch Size: " << cfg.model.batch_size << std::endl;
}

void printNetworkConfig(const config::NetworkConfig& cfg) {
    std::cout << "\n=== Network Config ===" << std::endl;
    std::cout << "TCP Server Enabled: " << (cfg.tcp.server.enabled ? "Yes" : "No") << std::endl;
    std::cout << "TCP Server IP: " << cfg.tcp.server.ip << std::endl;
    std::cout << "TCP Server Port: " << cfg.tcp.server.port << std::endl;
    std::cout << "Max Connections: " << cfg.tcp.server.max_connections << std::endl;
}

void printDisplayConfig(const config::DisplayConfig& cfg) {
    std::cout << "\n=== Display Config ===" << std::endl;
    std::cout << "Window Title: " << cfg.window.title << std::endl;
    std::cout << "Window Size: " << cfg.window.width << "x" << cfg.window.height << std::endl;
    std::cout << "Fullscreen: " << (cfg.window.fullscreen ? "Yes" : "No") << std::endl;
    std::cout << "FPS: " << cfg.window.fps << std::endl;
    std::cout << "Show FPS: " << (cfg.content.show_fps ? "Yes" : "No") << std::endl;
    std::cout << "Show Detection: " << (cfg.content.show_detection ? "Yes" : "No") << std::endl;
}

int main() {
    auto& configReader = config::ConfigReader::getInstance();
    
    if (!configReader.init()) {
        std::cerr << "Failed to initialize config reader" << std::endl;
        return 1;
    }

    std::cout << "Configuration loaded successfully!" << std::endl;

    // 打印所有配置信息
    printSoftwareConfig(configReader.getSoftwareConfig());
    printCameraConfig(configReader.getCameraConfig());
    printAlgorithmConfig(configReader.getAlgorithmConfig());
    printNetworkConfig(configReader.getNetworkConfig());
    printDisplayConfig(configReader.getDisplayConfig());

    return 0;
} 